package top.yxqz.ck;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Mr.余
 * @date 2022/11/24
 * @package top.yxqz.ck
 */
@WebServlet("/demo4")
public class CookieDemo4 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Cookie[] cookies = request.getCookies();
        for (Cookie ck : cookies
        ) {
            String name = ck.getName();
            String value = ck.getValue();
            System.out.println("name:"+name+"\tvalue:"+value);
            String path = ck.getPath();
            int maxAge = ck.getMaxAge();
            String domain = ck.getDomain();
            System.out.println("path:"+path);
            System.out.println("maxAge:"+maxAge);
            System.out.println("domain:"+domain);
        }
    }
}
